﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using QL_DTTN.DAL;
namespace QL_DTTN.DTO.DTO
{
    public partial class KyThi
    {
        public KyThi GetKyThi(long maKyThi)
        {
            bool kt = false;
            string sql = " select MaKyThi,TenKyThi,NamThi from " + _tableName + " where MaKyThi=@pMaKyThi ";
            SqlDataProvider dp = new SqlDataProvider();
            dp.AddParameter(new SqlParameter("@pMaKyThi", maKyThi));
            System.Data.SqlClient.SqlDataReader sqlRr = dp.ExDataReader(sql, true);
            KyThi dt = new KyThi();
            if (sqlRr != null)
            {
                while (sqlRr.Read())
                {

                    if (!Convert.IsDBNull(sqlRr["MaKyThi"])) dt.MaKyThi = Convert.ToInt64(sqlRr["MaKyThi"]);
                    if (!Convert.IsDBNull(sqlRr["TenKyThi"])) dt.TenKyThi = sqlRr["TenKyThi"].ToString();
                    if (!Convert.IsDBNull(sqlRr["NamThi"])) dt.NamThi = sqlRr["NamThi"].ToString();
                    kt = true;
                }
                dp.CloseConnection();
                if (kt) return dt;
                else return null;
            }
            else
            {
                return null;
            }
        }
    }
}
